#ifndef MESH
#define MESH

#include "material.h"

#include "vertex.h"
#include "index.h"

#include "format/3ds.h"
#include "format/mtl.h"
#include "format/obj.h"
#include "format/txt.h"
#include "format/x.h"

namespace sleek
{
    namespace node { namespace physics { class Physics; } }
    namespace texture { class draw; }
    namespace mesh
    {
        class Geometry;
        class MeshBuffer
        {
            public:
                MeshBuffer();
                ~MeshBuffer();

                enum VBO_BUFFER_TYPE
                {
                    VERTEX_BUFFER,
                    COLOR_BUFFER,
                    TEXTURE_COORD_BUFFER,
                    NORMAL_BUFFER,
                    INDEX_BUFFER
                };
                enum VBO_BUFFER_ALIGNMENT
                {
                    VBO_STATIC,
                    VBO_DYNAMIC
                };

                virtual void updatePhysics();
                //virtual void enablePhysics(node::physics::body_geometry);

                virtual void clear();
                virtual void recalculateBoundingBox();
                virtual core::math::aabbox3df getBoundingBox();

                virtual void createVBO(VBO_BUFFER_ALIGNMENT t = VBO_DYNAMIC);
                virtual void bindVBO(VBO_BUFFER_TYPE);
                virtual void updateVBO();
                virtual void destroyVBO();
                virtual void updateNormal();

                virtual bool isActivedVBO();

                core::math::array<vertex> vertices;
                core::math::array<index>  indices;
            protected:
                friend class Geometry;
                friend class texture::draw;
                friend class node::physics::Physics;

                bool vbo;
                core::math::aabbox3df box;
                core::math::vector3df scale;
                unsigned int vbovert, vbonorm, vbocoord, vbocolor, vboindi;
        };
    }
}

#endif
